IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'MailboxCreate')
	BEGIN
		DROP  Procedure  MailboxCreate
	END

GO

CREATE Procedure MailboxCreate
(
	@accountId int,
	@title nvarchar(200),
	@password nvarchar(50),
	@mailboxId int OUTPUT,
	@serviceId int OUTPUT
)
AS

EXEC ServiceCreate @accountId = @accountId, @title = @title, @serviceId = @serviceId OUTPUT

INSERT INTO Mailboxes
	(ServiceId, Password)
VALUES
	(@serviceId, @password)
	
SET @mailboxId = SCOPE_IDENTITY()

GO